<!--suppress ALL -->
<template>
    <div class="page apply-page apply-page-flow" data-page="apply">
        <div class="apply-page-top">
            <div class="apply-page-title">工作台</div>
            <div class="apply-page-sub-title">在这里开始你的消防工作</div>
            <div class="more-task-btn device-identification applyScan" id="device-identification_{{getNewId}}">
                    <i class="iconfont icon-APPicon_yijianbaojing- " style="font-size:32px;margin-top: 8px;margin-left: -60px;"
                    @click="gowarning"> </i>
                <i class="iconfont icon-saoyisao" style="font-size:32px;margin-top: 8px;margin-left: 10px;"
                @click="scanning"> </i>
            </div>
        </div>
        <div class="page-content ptr-content" style="padding-top: 20px;"
            @ptr:refresh="refreshCurrent">
            <div class="ptr-preloader" id="refresh_apply" style="top: 30px;">
                <div class="preloader color-multi"></div>
                <div class="ptr-arrow"></div>
            </div>
            <div class="list apply-page-list">
                <div>
                    <P class="apple_content_title">实时监测</P>
                    <ul>
                        <li class="apply-permiss apply_content_li">
                            <a href="/fireHazardList/1/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_gaoweixinhao"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">高危信号</div>
                            <div class="apply_content_circle" id="apply_content_circle_gaoweixinhao" style="display: none;"></div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                            <a href="/keyIssuesList/1/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_zhongdawenti"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">重大问题</div>
                            <div class="apply_content_circle" id="apply_content_circle_zhongdawenti" style="display: none;"></div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                            <a href="/historyPoliceApply/0/-1/0/0/0/0/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_jiechujing"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">接处警</div>
                            <div class="apply_content_circle" id="apply_content_circle_jiechujing" style="display: none;"></div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="#" class="item-link item-content" id="eqState">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_shebeiwulian"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">设备物联</div>
                        </li>
                        <div style="clear:both;"></div>
                    </ul>
                </div>
                <div>
                    <P class="apple_content_title">日常运维</P>
                    <ul>
                        <li class="apply-permiss apply_content_li">
                                <a href="/clockIn/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_daka"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">打卡</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/signIn/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_qiandao"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">签到签退</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/inspectionApply/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_chagang"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">查岗</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/changeShifts/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_jiaojieban"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">交接班</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/temporaryTask/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_linshirenwu"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">临时任务</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/workApply/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_zuoyeshenqing"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">作业申请</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/troubleApply/0/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_yinhuanzhenggai"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">隐患整改</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/checkApply/0/0/0/0/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_richangxunjian"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">日常巡检</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/maintainInspect/1/-1/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_weibaoxuncha"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">维保巡查</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/maintain/2/-1/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_baoyang"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">保养</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/singleTest/1/-1/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_dandianceshi"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">单点测试</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/linkTest/1/-1/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_liandongceshi"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">联动测试</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                            <a href="#" class="item-link item-content" id="eqStateRemoteControl">
                            <div class="item-media apply_content_media">
                                <svg class="icon apply_content_icon" aria-hidden="true">
                                    <use xlink:href="#icon-a-yuanchengxiezhu1"></use>
                                </svg>
                            </div>
                        </a>
                            <div class="apply_content_text">远程控制</div>
                        </li>
                        <div style="clear:both;"></div>
                    </ul>
                </div>
                <div>
                    <P class="apple_content_title">其它</P>
                    <ul>
                        <li class="apply-permiss apply_content_li">
                            <a href="/planLibraryApply/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_yingjiyuan"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">应急预案</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                            <a href="/dealEmergencyApply/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_yingjijiuyuan"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">应急救援</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                            <a href="/closeReminder/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_guanbibaojing"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">关闭报警</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="#" id="href_reportApply" class="item-link item-content" link-data="reportApply">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_baobiao"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">报表</div>
                            <div class="apply_content_circle" id="apply_content_circle_baobiao" style="display: none;"></div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a  class="item-link item-content" id="assetsApply" link-data="assetsList" @click="changeFlag">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_zichan"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text" >资产</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a class="item-link item-content" id="filesLib">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_dangan"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">档案</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                            <a href="/study/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_xuexi"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">学习</div>
                        </li>
                        <li class="apply-permiss apply_content_li">
                                <a href="/exam/" class="item-link item-content">
                                <div class="item-media apply_content_media">
                                    <svg class="icon apply_content_icon" aria-hidden="true">
                                        <use xlink:href="#icon-xinbangongzuotaitubiao_kaoshi"></use>
                                    </svg>
                                </div>
                            </a>
                            <div class="apply_content_text">考试</div>
                        </li>
                        <div style="clear:both;"></div>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
return {
    data: function() {
        return {}
    },
    methods: {
        backToRefresh:function(){
            var self = this;
            self.getAllStatus();
        },
        changeFlag:function(){
            IfJzwFlag=true

        },
        gowarning:function(){
            app.router.navigate("/oneAlarm/");
        },
        getAllStatus: function() {
            Dao.getWorkPlatCalc_ajax({
                orgIds:userInfor.organizationIds,
                types:"1,2,3,4",
                platOrgId:userInfor.org.id // 因为报表改了 得加个参数 其他不变 platOrgId：num  当前用户所在组织的orgId
            },function(data){
                if(data){
                    for(let i=0;i<data.length;i++){
                        if(data[i].type == 1 || data[i].type == 2){
                            if(data[i].type == 1 && data[i].data>0){
                                jQuery('#apply_content_circle_gaoweixinhao').show();//高危信号
                            }else if(data[i].data>0){
                                jQuery('#apply_content_circle_zhongdawenti').show();//重大问题
                            }
                        }else if(data[i].type == 3 && data[i].totalCount>0){
                            jQuery('#apply_content_circle_jiechujing').show();//接处警
                        }else if(data[i].type == 4){
                            //jQuery('#apply_content_circle_baobiao').show();//报表暂时不做
                        }
                    }
                }
            }); 
        },
        refreshCurrent:function (e, done) {
            var self = this;
            var $ = self.$$;
            // var applyArr = jQuery(".apply-permiss");
            // if (userInfor.resources.length>0) {
            //     for (var i = 0; i < userInfor.resources.length; i++) {
            //         for(var n=0;n<applyArr.length;n++){
            //             if(applyArr[n].children[0].pathname.split("/")[1] == userInfor.resources[i].link || 
            //                 jQuery(applyArr[n].children).attr("link-data") == userInfor.resources[i].link){
            //                 jQuery(applyArr[n]).children().find(".item-title span").html(userInfor.resources[i].resourceName);
            //                 jQuery(applyArr[n]).show();
            //             }
            //         }
            //     }
            // }
            if(1 === e){
                common.loading(1);
            }
            if (done && e) {
                setTimeout(function () {
                    self.getAllStatus();
                    done();
                    if(1 === e){
                        common.loading(0);
                    }
                },1000);
            }
        },
        //原生扫一扫
        scanning: function () {
            native.scanQrCode();
        },
    },
    on: {
        pageInit: function(e, page) {
            var self = this;
            var reportApplyChoicePageRoleIds= [141,153,172,177];//可以看到选择报表种类页面的角色id
            var showReportApplyChoicePageFlag = false;
            var year=new Date().getFullYear()
            var times=new Date().getTime()
            var isTest=location.origin.indexOf('192.168.2.242')>-1||location.origin.indexOf('112.30.116.14')>-1
            // 每一年的1月1号到7号展示年报banner
            var isInDate=times>=new Date(`${year}/01/01 00:00:00`).getTime()&&times<=new Date(`${year}/01/31 00:00:00`).getTime()
            // var showBanner=!localStorage.getItem(`${userInfor.id}__${year-1}`)&&isInDate
            var showBanner=isInDate
            var isMulti=userInfor.isMuilUnitUser == 1
            var orgName=userInfor.org.name

            jQuery.each(userInfor.role, (index, obj) => {
                if(reportApplyChoicePageRoleIds.indexOf(obj.id)>-1){
                    showReportApplyChoicePageFlag = true
                    return false;
                }
            }) 
            $('#href_reportApply').attr('href', showReportApplyChoicePageFlag?'/reportApplyChoice/': ('/reportApply/'+ userInfor.organizationIds+'/1/'));
            $('#bannerYearReport').remove()
            //多
            if (isMulti) {
                $("#eqState").attr('href', '/moreDectorState/1/0/11/2/');
                $("#eqStateRemoteControl").attr('href', '/remoteControl/1/0/11/2/');
                $("#assetsApply").attr('href', '/assetsListForMore/');
                $("#filesLib").attr('href', '/filesLib/');
            } 
            //单联网
            else { 
                $("#eqState").attr('href', '/moreDectorState/0/' + userInfor.organizationIds + '/11/2/');
                $("#eqStateRemoteControl").attr('href', '/remoteControl/0/' + userInfor.organizationIds + '/11/2/');
                $("#assetsApply").attr('href', '/assetsListForSingle/'+ userInfor.organizationIds + '/'+ 0 +'/'+ 0 +'/');
                $("#filesLib").attr('href', '/filesLib/'+ userInfor.organizationIds + '/');   
            }
            if(showBanner){
                Dao.getYearReportId({
                    orgId:userInfor.org.id
                },(data)=>{
                    console.log('data',data)
                    if(data){
                        $('.apply-page-list').prepend(`<img id="bannerYearReport" src="${staticPath}img/yearReport/banner-${isMulti?'platform':'unit'}-${year-1}.png">`)
                        $('#bannerYearReport').click(()=>{
                            app.router.navigate(`/reportApplyDetail/${data}/${isMulti?'4':'3'}/${orgName}/${year-1}/3/`);
                            localStorage.setItem(`${userInfor.id}__${year-1}`,'1')
                        })
                    }
                })
            }

        },
        /*
        * resourceType 可能的值有：null 1  2  1,2
        1:对单位用户是重点
        2：对支队用户是重点
        1,2 : 对所有用户都是重点
        */
        pageAfterIn: function(e, page) {
            //resourceType == 1 重要
            var applyArr = jQuery(".apply-permiss");
            if (userInfor.resources.length>0) {
                for (var i = 0; i < userInfor.resources.length; i++) {
                    for(var n=0;n<applyArr.length;n++){
                        if(applyArr[n].children[0].pathname.split("/")[1] == userInfor.resources[i].link || 
                            jQuery(applyArr[n].children).attr("link-data") == userInfor.resources[i].link){
                            jQuery(applyArr[n]).children().find(".item-title span").html(userInfor.resources[i].resourceName);
                            jQuery(applyArr[n]).show();
                        }
                    }
                }
            }
            //获取统计
            this.getAllStatus();
        }
    },
}
</script>
<style scoped>
    .apply-page-list #bannerYearReport{
        width:100%;
    }
    .applyScan{
        top: 14px;
    }
    .more-task-btn .iconfont{
        color:black;
    }
    .more-task-btn{
        background:white;
    }
    .apply_content_text{
        font-size: 12px;
    }
    .apply_content_li{
        width: 25%;
        display: list-item;
        float: left;
        text-align: center;
        margin-top: 6px;
        display: none;
    }
    .apply_content_media{
        margin-left: calc(50% + -17px);
    }
    .apple_content_title{
        font-weight:bold;
        font-size: 14px;
        margin-top: 17px;
    }
    .apply_content_icon{
        font-size: 34px;
    }
    .apply_content_div{
        padding-top: 10px;
    }
    .apply_content_circle{
        width: 8px;
        height: 8px;
        background: red;
        -moz-border-radius: 4px;
        -webkit-border-radius: 4px;
        border-radius: 9px;
        position: absolute;
        left: 53px;
        top: 6px;
        border: 2px solid white;
    }
</style>